window.addEventListener('load', function() {
    const conurse = document.querySelector('.search-l-cir');
    const course_selet = document.querySelector('.course-selet');
    const course_spans = course_selet.querySelectorAll('span');
    // console.log(course_spans)
    const up_arrow = document.querySelector('.course-ico');
    const hd = this.document.querySelector('.hd')
    const selet_all = this.document.querySelector('.search-l-cir');
    // const navSpansAll = document.querySelectorAll('.nav ul>li');
    // console.log(navSpansAll)
    hd.onmouseleave = function() {
        course_selet.style.display = 'none';
        up_arrow.innerHTML = '';
        course_selet.onmouseleave = function() {
            this.style.display = 'none';
            up_arrow.innerHTML = '';
        };
    }
    conurse.onmousemove = function() {
        course_selet.style.display = 'block';
        selet_all.children[1].innerHTML = '';
    };

    // 课程点击换字体
    for (var i = 0; i < course_spans.length; i++) {
        course_spans[i].onclick = function() {
            for (var i = 0; i < course_spans.length; i++) {
                course_spans[i].className = '';
            };
            this.className = "current";

            course_selet.style.display = 'none';
            let character = this.innerHTML;
            selet_all.children[0].innerHTML = character;
            // console.log(character)
            up_arrow.innerHTML = '';
            up_arrow.style.paddingBottom = 5 + 'px';
        }
    }

    // function sieVe(obj, on, par) {
    //     for (var i = 0; i < obj.length; i++) {
    //         obj[i].on = function() {
    //             for (var i = 0; i < obj.length; i++) {
    //                 obj[i].className = '';
    //             };
    //             this.className = par;
    //         };
    //     }
    // }
    //
    const nav_lis = document.querySelectorAll('.nav ul li');
    for (var i = 0; i < nav_lis.length; i++) {
        nav_lis[i].onmousemove = function() {
            for (var i = 0; i < nav_lis.length; i++) {
                nav_lis[i].className = '';
            };
            this.className = 'nav-bottom';
        };
    }
    //右侧栏换色
    const ol_lis = document.querySelectorAll('.menu li');
    for (var i = 0; i < ol_lis.length; i++) {
        ol_lis[i].onmousemove = function() {
            for (var i = 0; i < ol_lis.length; i++) {
                ol_lis[i].children[0].className = '';
                ol_lis[i].children[1].className = '';
            };
            this.children[0].className = 'menublock'
            this.children[1].className = 'menublock-current '
        };
    }
    // 上下跳动
    const hot_items = document.querySelector('.hot-items');
    var hot_items_left = hot_items.offsetTop;
    // console.log(hot_items_left)
    this.setInterval(function() {
        if (hot_items_left > -16) {
            hot_items_left--;
            console.log(hot_items_left);
            hot_items.style.top = hot_items_left + 'px';
        } else {
            hot_items_left++;
            console.log(hot_items_left);
            hot_items.style.top = hot_items_left + 'px';
        }

    }, 500);
})